﻿angular.module('projectItemStatusFilters', []).filter('checkProjectItemStatus', function () {
    return function (input) {
        switch (input) {
            case 0:
                return "邀请中";
            case 1:
                return "邀请成功";
            case 2:
                return "邀请失败";
            case 5:
                return "完成";
            case 7:
                return "邀请过期";
            case 8:
                return "活动进行中"
        }
    };
});
angular.module('projectStatusFilters', []).filter('checkProjectStatus', function () {
    return function (input) {
        switch (input) {
            case 0:
                return "审核中";
            case 1:
                return "发布中";
            case 4:
                return "审核失败";
            case 3:
                return "合作完成";
            case 2:
                return "活动进行中";
            case 5:
                return "活动已经取消";
        }
    };
});

angular.module('chooseTypeFilters', []).filter('checkChooseType', function () {
    return function (input) {
        switch (input) {
            case 0:
                return "选择我的";
            case 1:
                return "我自选的";
            case 2:
                return "智慧搭配";
        }
    };
});

angular.module('MoneyStatusFilters', []).filter('MoneyStatusType', function () {
    return function (input) {
        switch (input) {
            case 0:
                return "未付款";
            case 1:
                return "已经付款";
            case 2:
                return "获得首款";
            case 3:
                return "获得尾款";
        }
    };
});


angular.module('AssociationGradeFilters', []).filter('AssociationGrade', function () {
    return function (input) {
       
        switch (input) {
            case 0:
            case "0":
                return "普通社团";
            case "1":
            case 1:
                return "金牌社团";
            case "2":
            case 2:
                return "官方代理社团";
        }
    };
});

var app = angular.module('myApp', ['projectStatusFilters', 'projectItemStatusFilters', 'chooseTypeFilters', 'MoneyStatusFilters','AssociationGradeFilters']);

app.controller('newShopCtrl', function ($http, $scope) {
    //list
    $http.get('../api/User/get/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('companyProjectCtrl', function ($http, $scope) {
    //list
    $http.get('../api/enterprise/get/').success(function (data) {

        if (data == null)
            window.location = "login.html";

        $scope.names = data;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });

});

app.controller('studentProjectCtrl', function ($http, $scope) {
    //list
    $http.get('../api/student/Myactivity/').success(function (data) {
      
        if (data == null)
            window.location = "login.html";

        $scope.names = data;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });

});

app.controller('activityDetailsCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/get/0').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseObj;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('sysChooseAssocCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListSysChooseAssoc/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('selfChooseAssocCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListSelfChooseAssoc/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('sysChooseEntrCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListSysChooseEnter/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('selfChooseEntrCtrl', function ($http, $scope) {

    //list
    $http.get('../api/project/ListSelfChooseEnter/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('sysAssocCtrl', function ($http, $scope) {

    //list
    $http.get('../api/project/ListSysChoAssocForSuc/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('selfAssocCtrl', function ($http, $scope) {

    //list
    $http.get('../api/project/ListSelfChoAssocForSuc/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('pickedAssocCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListPickChoAssocForSuc/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('assocByLikeCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListAssocByLikeForIndex/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('assocByNewCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListAssocByNewsIndex/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('latestAssocCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListLatestAssocForIndex/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('selfCancelCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListSelfCancelAct/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('assocBooksCtrl', function ($http, $scope) {
    //list
    $http.get('../api/student/ListAssociationBooks/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('assocStudentCtrl', function ($http, $scope) {
    //list
    $http.get('../api/student/ListAssociationBind/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('myAssocCtrl', function ($http, $scope) {
    //list
    $http.get('../api/student/MyAssociation/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});


app.controller('cancelledCtrl', function ($http, $scope) {
    //list
    $http.get('../api/project/ListCancelledAct/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('companyAccountCtrl', function ($http, $scope) {
    //list
    $http.get('../api/enterprise/ListAccountInfo/').success(function (data) {
        if (data == null)
            window.location = "login.html";
        $scope.names = data.ResponseList;
    }).error(function (data, status, headers, config) {
        common.alertMessage(data.Message, status);
    });
});

app.controller('companyPayCtrl', function ($http, $scope) {
    //list
    $http.get('../api/enterprise/ListPayInfo/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});


app.controller('studentInfoCtrl', function ($http, $scope) {

    //list
    $http.get('../api/student/GetInfo/').success(function (data) {

        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseDict;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});
app.controller('assocCreatedByMeCtrl', function ($http, $scope) {
    //list
    $http.get('../api/student/GetMyAssociationInfo/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseDict;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});


app.controller('companyInfoCtrl', function ($http, $scope) {

    //list
    $http.get('../api/enterprise/get/0').success(function (data) {

        if (data == null)
            window.location = "login.html";
        else if (data == "transfer")
            window.location = "guide.html";

        $scope.names = data.ResponseObj;
        $scope.names.Sex = data.ResponseObj.User.Sex == 0 ? "男" : "女";
        for (var i = 0; i < data.ResponseObj.Files.length; i++) {
            switch (data.ResponseObj.Files[i].Fun) {
                case 0:
                    $scope.names.IDFront = data.ResponseObj.Files[i].Path;
                    break;
                case 1:
                    $scope.names.IDOpposite = data.ResponseObj.Files[i].Path;
                    break;
                case 3:
                    $scope.names.License = data.ResponseObj.Files[i].Path;
                    break;
            }
        }

    }).error(function (data, status, headers, config) {

        switch (status) {
            case 400:
                alert(data.Message);
                break;
            case 401:
                window.location = "../login.html";
                break;
            case 404:
                window.location = "guide.html";
                break;
        }
    });
});

app.controller('adminAuditCtrl', function ($http, $scope) {
    //list
    $http.get('../api/admin/CompanyAudit/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});

app.controller('adminbookCtrl', function ($http, $scope) {
    //list
    $http.get('../api/admin/CompanyBook/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});

app.controller('adminAssoCtrl', function ($http, $scope) {
    //list
    $http.get('../api/admin/AssoInfo/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});

app.controller('adminStudentCtrl', function ($http, $scope) {
    //list
    $http.get('../api/admin/StudentInfo/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});


app.controller('adminAssoBook', function ($http, $scope) {
    //list
    $http.get('../api/admin/AssoBook/').success(function (data) {
        if (data == null)
            window.location = "login.html";

        $scope.names = data.ResponseList;

    }).error(function (data, status, headers, config) {

        common.alertMessage(data.Message, status);
    });
});




